package cn.tedu._04mvcboot02.common.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import springfox.documentation.spring.web.json.Json;

@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class JsonResult {
    private Integer code;
    private String msg;
    private Object data;

    /**
     * 1.没有具体数据返回的Controller方法
     */
    public JsonResult(StatusCode statusCode){
        this.code = statusCode.getCode();
        this.msg = statusCode.getMsg();
    }

    /**
     * 2.有具体数据返回的Controller方法
     */
    public JsonResult(StatusCode statusCode, Object data){
        this(statusCode);
        this.data = data;
    }
}
